package com.katarina.ad.panels;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.katarina.ad.panels.menu.LeftMenu;
import com.katarina.ad.service.SampleService;
import com.vaadin.terminal.Sizeable;
import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalSplitPanel;

@Component("rootPanel")
public class RootPanel extends VerticalSplitPanel {
  private static final long serialVersionUID = 3499563011673387768L;

  private static final Logger logger = LoggerFactory.getLogger(RootPanel.class);
  //  private VerticalSplitPanel verticalSplitPanel;
  //  private HorizontalSplitPanel horizontalSplitPanel;

  @Autowired
  private LeftMenu leftMenu;

  @Autowired
  private MainPanel mainPanel;

  @Autowired
  private SampleService sampleService;

  @PreDestroy
  public void destroy() {
    leftMenu = null;
    mainPanel = null;
  }

  @PostConstruct
  public void init() {
    setSizeFull();
    Label testLabel = new Label("doremi");
    addComponent(testLabel);
    setSplitPosition(3, Sizeable.UNITS_PERCENTAGE);
    HorizontalSplitPanel horizontalLayout = new HorizontalSplitPanel();
    horizontalLayout.setSizeFull();
    horizontalLayout.addComponent(leftMenu);
    horizontalLayout.addComponent(mainPanel);
    horizontalLayout.setSplitPosition(20, Sizeable.UNITS_PERCENTAGE);
    horizontalLayout.setLocked(true);
    setLocked(true);
    addComponent(horizontalLayout);
  }
}